#include "UdpServer.hpp"
#include <string>
#include <strings.h>
#include "Dictionary.hpp"

int main(int argc, char* argv[])
{

    uint16_t port = 8080;
    std::string ip = "192.168.8.16";
    sockaddr_in local;
    bzero(&local, sizeof(local));
    local.sin_addr.s_addr = inet_addr(ip.c_str());
    local.sin_family = AF_INET;
    local.sin_port = htons(port);
    InetAddr serIAddr(local);
     // 1. 字典对象提供翻译功能
    Dict dict;
    dict.Load();
    
    // 2. 网络服务器对象，提供通信功能
    std::unique_ptr<Server> usvr = std::make_unique<Server>(serIAddr, [&dict](const std::string &word, InetAddr&cli)->std::string{
        return dict.Translate(word, cli);
    });
    usvr->Init();
    usvr->Start();
    return 0;
}